// Unless explicitly stated otherwise all files in this repository are licensed
// under the MIT License.
// This product includes software developed at Guance Cloud (https://www.guance.com/).
// Copyright 2021-present Guance, Inc.

package clickhousev1

import (
	"time"

	"gitlab.jiagouyun.com/cloudcare-tools/datakit/io"
	"gitlab.jiagouyun.com/cloudcare-tools/datakit/plugins/inputs"
)

type ProfileEventsMeasurement struct {
	name   string
	tags   map[string]string
	fields map[string]interface{}
	ts     time.Time
}

type MetricsMeasurement struct {
	name   string
	tags   map[string]string
	fields map[string]interface{}
	ts     time.Time
}

type AsyncMetricsMeasurement struct {
	name   string
	tags   map[string]string
	fields map[string]interface{}
	ts     time.Time
}

type StatusInfoMeasurement struct {
	name   string
	tags   map[string]string
	fields map[string]interface{}
	ts     time.Time
}

func (m *ProfileEventsMeasurement) LineProto() (*io.Point, error) {
	return io.MakePoint(m.name, m.tags, m.fields, m.ts)
}

func (m *MetricsMeasurement) LineProto() (*io.Point, error) {
	return io.MakePoint(m.name, m.tags, m.fields, m.ts)
}

func (m *AsyncMetricsMeasurement) LineProto() (*io.Point, error) {
	return io.MakePoint(m.name, m.tags, m.fields, m.ts)
}

func (m *StatusInfoMeasurement) LineProto() (*io.Point, error) {
	return io.MakePoint(m.name, m.tags, m.fields, m.ts)
}

func (m *AsyncMetricsMeasurement) Info() *inputs.MeasurementInfo {
	return &inputs.MeasurementInfo{
		Name: "ClickHouseAsyncMetrics",
		Type: "metric",
		Fields: map[string]interface{}{
			"AsynchronousMetricsCalculationTimeSpent":  newGaugeFieldInfo(inputs.TODO),
			"jemalloc_arenas_all_pmuzzy":               newGaugeFieldInfo(inputs.TODO),
			"jemalloc_arenas_all_pactive":              newGaugeFieldInfo(inputs.TODO),
			"FilesystemLogsPathUsedINodes":             newGaugeFieldInfo(inputs.TODO),
			"jemalloc_background_thread_run_intervals": newGaugeFieldInfo(inputs.TODO),
			"jemalloc_mapped":                          newGaugeFieldInfo(inputs.TODO),
			"BlockReadTime_dm_0":                       newGaugeFieldInfo(inputs.TODO),
			"jemalloc_resident":                        newGaugeFieldInfo(inputs.TODO),
			"FilesystemMainPathTotalBytes":             newGaugeFieldInfo(inputs.TODO),
			"jemalloc_metadata_thp":                    newGaugeFieldInfo(inputs.TODO),
			"jemalloc_metadata":                        newGaugeFieldInfo(inputs.TODO),
			"MySQLThreads":                             newGaugeFieldInfo(inputs.TODO),
			"Jitter":                                   newGaugeFieldInfo(inputs.TODO),
			"TotalRowsOfMergeTreeTables":               newGaugeFieldInfo(inputs.TODO),
			"TotalBytesOfMergeTreeTables":              newGaugeFieldInfo(inputs.TODO),
			"CompiledExpressionCacheCount":             newGaugeFieldInfo(inputs.TODO),
			"NumberOfTables":                           newGaugeFieldInfo(inputs.TODO),
			"NumberOfDatabases":                        newGaugeFieldInfo(inputs.TODO),
			"ReplicasMaxAbsoluteDelay":                 newGaugeFieldInfo(inputs.TODO),
			"ReplicasMaxMergesInQueue":                 newGaugeFieldInfo(inputs.TODO),
			"ReplicasMaxInsertsInQueue":                newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveBytes_virbr0_nic":           newGaugeFieldInfo(inputs.TODO),
			"DiskAvailable_default":                    newGaugeFieldInfo(inputs.TODO),
			"DiskUsed_default":                         newGaugeFieldInfo(inputs.TODO),
			"FilesystemLogsPathTotalINodes":            newGaugeFieldInfo(inputs.TODO),
			"FilesystemLogsPathAvailableByte":          newGaugeFieldInfo(inputs.TODO),
			"FilesystemMainPathUsedINodes":             newGaugeFieldInfo(inputs.TODO),
			"OSSystemTimeNormalized":                   newGaugeFieldInfo(inputs.TODO),
			"FilesystemMainPathTotalINodes":            newGaugeFieldInfo(inputs.TODO),
			"MemoryDataAndStack":                       newGaugeFieldInfo(inputs.TODO),
			"NetworkSendErrors_virbr0_nic":             newGaugeFieldInfo(inputs.TODO),
			"NetworkSendPackets_virbr0_nic":            newGaugeFieldInfo(inputs.TODO),
			"PostgreSQLThreads":                        newGaugeFieldInfo(inputs.TODO),
			"NetworkSendBytes_virbr0_nic":              newGaugeFieldInfo(inputs.TODO),
			"InterserverThreads":                       newGaugeFieldInfo(inputs.TODO),
			"ReplicasMaxQueueSize":                     newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveDrop_virbr0_nic":            newGaugeFieldInfo(inputs.TODO),
			"DiskUnreserved_default":                   newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveErrors_virbr0_nic":          newGaugeFieldInfo(inputs.TODO),
			"NetworkSendPackets_virbr0":                newGaugeFieldInfo(inputs.TODO),
			"NetworkSendBytes_virbr0":                  newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveBytes_virbr0":               newGaugeFieldInfo(inputs.TODO),
			"NetworkSendPackets_ens33":                 newGaugeFieldInfo(inputs.TODO),
			"NetworkSendBytes_ens33":                   newGaugeFieldInfo(inputs.TODO),
			"OSSoftIrqTimeNormalized":                  newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveErrors_ens33":               newGaugeFieldInfo(inputs.TODO),
			"TCPThreads":                               newGaugeFieldInfo(inputs.TODO),
			"BlockActiveTime_dm_0":                     newGaugeFieldInfo(inputs.TODO),
			"BlockActiveTimePerOp_dm_1":                newGaugeFieldInfo(inputs.TODO),
			"DiskTotal_default":                        newGaugeFieldInfo(inputs.TODO),
			"FilesystemLogsPathUsedBytes":              newGaugeFieldInfo(inputs.TODO),
			"NetworkSendErrors_virbr0":                 newGaugeFieldInfo(inputs.TODO),
			"BlockQueueTime_dm_1":                      newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardTime_dm_1":                    newGaugeFieldInfo(inputs.TODO),
			"BlockReadTime_dm_1":                       newGaugeFieldInfo(inputs.TODO),
			"HTTPThreads":                              newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardMerges_dm_1":                  newGaugeFieldInfo(inputs.TODO),
			"PrometheusThreads":                        newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveDrop_ens33":                 newGaugeFieldInfo(inputs.TODO),
			"OSMemoryTotal":                            newGaugeFieldInfo(inputs.TODO),
			"BlockWriteMerges_dm_1":                    newGaugeFieldInfo(inputs.TODO),
			"ReplicasSumQueueSize":                     newGaugeFieldInfo(inputs.TODO),
			"BlockReadMerges_dm_1":                     newGaugeFieldInfo(inputs.TODO),
			"BlockWriteMerges_sr0":                     newGaugeFieldInfo(inputs.TODO),
			"BlockWriteBytes_sda":                      newGaugeFieldInfo(inputs.TODO),
			"BlockWriteOps_dm_1":                       newGaugeFieldInfo(inputs.TODO),
			"BlockInFlightOps_sr0":                     newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardTime_sr0":                     newGaugeFieldInfo(inputs.TODO),
			"FilesystemMainPathAvailableINodes":        newGaugeFieldInfo(inputs.TODO),
			"BlockReadMerges_dm_0":                     newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardBytes_sr0":                    newGaugeFieldInfo(inputs.TODO),
			"BlockWriteBytes_sr0":                      newGaugeFieldInfo(inputs.TODO),
			"ReplicasSumMergesInQueue":                 newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardMerges_sr0":                   newGaugeFieldInfo(inputs.TODO),
			"BlockReadOps_dm_1":                        newGaugeFieldInfo(inputs.TODO),
			"BlockReadMerges_sr0":                      newGaugeFieldInfo(inputs.TODO),
			"jemalloc_allocated":                       newGaugeFieldInfo(inputs.TODO),
			"OSSystemTime":                             newGaugeFieldInfo(inputs.TODO),
			"OSProcessesBlocked":                       newGaugeFieldInfo(inputs.TODO),
			"OSThreadsRunnable":                        newGaugeFieldInfo(inputs.TODO),
			"OSMemoryFreePlusCached":                   newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardOps_sr0":                      newGaugeFieldInfo(inputs.TODO),
			"BlockQueueTime_dm_0":                      newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardBytes_dm_1":                   newGaugeFieldInfo(inputs.TODO),
			"OSGuestTimeNormalized":                    newGaugeFieldInfo(inputs.TODO),
			"BlockWriteTime_dm_0":                      newGaugeFieldInfo(inputs.TODO),
			"BlockQueueTime_sda":                       newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveDrop_virbr0":                newGaugeFieldInfo(inputs.TODO),
			"BlockReadOps_sda":                         newGaugeFieldInfo(inputs.TODO),
			"jemalloc_epoch":                           newGaugeFieldInfo(inputs.TODO),
			"OSProcessesRunning":                       newGaugeFieldInfo(inputs.TODO),
			"BlockWriteBytes_dm_1":                     newGaugeFieldInfo(inputs.TODO),
			"OSContextSwitches":                        newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardBytes_dm_0":                   newGaugeFieldInfo(inputs.TODO),
			"jemalloc_arenas_all_dirty_purged":         newGaugeFieldInfo(inputs.TODO),
			"BlockWriteBytes_dm_0":                     newGaugeFieldInfo(inputs.TODO),
			"BlockReadOps_dm_0":                        newGaugeFieldInfo(inputs.TODO),
			"jemalloc_background_thread_num_threads":   newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardOps_dm_0":                     newGaugeFieldInfo(inputs.TODO),
			"BlockWriteOps_dm_0":                       newGaugeFieldInfo(inputs.TODO),
			"BlockActiveTime_sda":                      newGaugeFieldInfo(inputs.TODO),
			"FilesystemMainPathUsedBytes":              newGaugeFieldInfo(inputs.TODO),
			"BlockWriteTime_dm_1":                      newGaugeFieldInfo(inputs.TODO),
			"MMapCacheCells":                           newGaugeFieldInfo(inputs.TODO),
			"NetworkReceivePackets_ens33":              newGaugeFieldInfo(inputs.TODO),
			"BlockReadBytes_sda":                       newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardOps_sda":                      newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveBytes_ens33":                newGaugeFieldInfo(inputs.TODO),
			"OSStealTime":                              newGaugeFieldInfo(inputs.TODO),
			"MemoryCode":                               newGaugeFieldInfo(inputs.TODO),
			"BlockReadMerges_sda":                      newGaugeFieldInfo(inputs.TODO),
			"BlockWriteOps_sda":                        newGaugeFieldInfo(inputs.TODO),
			"OSMemorySwapCached":                       newGaugeFieldInfo(inputs.TODO),
			"FilesystemLogsPathTotalBytes":             newGaugeFieldInfo(inputs.TODO),
			"BlockInFlightOps_dm_0":                    newGaugeFieldInfo(inputs.TODO),
			"OSGuestNiceTimeNormalized":                newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardOps_dm_1":                     newGaugeFieldInfo(inputs.TODO),
			"OSOpenFiles":                              newGaugeFieldInfo(inputs.TODO),
			"MarkCacheFiles":                           newGaugeFieldInfo(inputs.TODO),
			"OSStealTimeNormalized":                    newGaugeFieldInfo(inputs.TODO),
			"jemalloc_retained":                        newGaugeFieldInfo(inputs.TODO),
			"BlockInFlightOps_dm_1":                    newGaugeFieldInfo(inputs.TODO),
			"OSIrqTimeNormalized":                      newGaugeFieldInfo(inputs.TODO),
			"MemoryVirtual":                            newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardTime_sda":                     newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardBytes_sda":                    newGaugeFieldInfo(inputs.TODO),
			"jemalloc_arenas_all_pdirty":               newGaugeFieldInfo(inputs.TODO),
			"OSIdleTimeNormalized":                     newGaugeFieldInfo(inputs.TODO),
			"OSInterrupts":                             newGaugeFieldInfo(inputs.TODO),
			"MemoryResident":                           newGaugeFieldInfo(inputs.TODO),
			"BlockReadTime_sda":                        newGaugeFieldInfo(inputs.TODO),
			"OSGuestNiceTimeCPU0":                      newGaugeFieldInfo(inputs.TODO),
			"OSIrqTime":                                newGaugeFieldInfo(inputs.TODO),
			"NetworkSendDrop_virbr0":                   newGaugeFieldInfo(inputs.TODO),
			"BlockQueueTimePerOp_dm_1":                 newGaugeFieldInfo(inputs.TODO),
			"jemalloc_arenas_all_muzzy_purged":         newGaugeFieldInfo(inputs.TODO),
			"OSStealTimeCPU0":                          newGaugeFieldInfo(inputs.TODO),
			"FilesystemLogsPathAvailableINodes":        newGaugeFieldInfo(inputs.TODO),
			"BlockReadBytes_dm_0":                      newGaugeFieldInfo(inputs.TODO),
			"TotalPartsOfMergeTreeTables":              newGaugeFieldInfo(inputs.TODO),
			"NetworkReceivePackets_virbr0_nic":         newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardMerges_sda":                   newGaugeFieldInfo(inputs.TODO),
			"BlockWriteOps_sr0":                        newGaugeFieldInfo(inputs.TODO),
			"BlockWriteTime_sda":                       newGaugeFieldInfo(inputs.TODO),
			"BlockQueueTime_sr0":                       newGaugeFieldInfo(inputs.TODO),
			"BlockActiveTime_sr0":                      newGaugeFieldInfo(inputs.TODO),
			"OSIOWaitTimeCPU0":                         newGaugeFieldInfo(inputs.TODO),
			"NetworkReceiveErrors_virbr0":              newGaugeFieldInfo(inputs.TODO),
			"NetworkSendDrop_ens33":                    newGaugeFieldInfo(inputs.TODO),
			"OSSystemTimeCPU0":                         newGaugeFieldInfo(inputs.TODO),
			"OSNiceTimeCPU0":                           newGaugeFieldInfo(inputs.TODO),
			"jemalloc_background_thread_num_runs":      newGaugeFieldInfo(inputs.TODO),
			"FilesystemMainPathAvailableBytes":         newGaugeFieldInfo(inputs.TODO),
			"OSUserTimeCPU0":                           newGaugeFieldInfo(inputs.TODO),
			"OSProcessesCreated":                       newGaugeFieldInfo(inputs.TODO),
			"BlockWriteMerges_sda":                     newGaugeFieldInfo(inputs.TODO),
			"OSNiceTime":                               newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardTime_dm_0":                    newGaugeFieldInfo(inputs.TODO),
			"BlockActiveTime_dm_1":                     newGaugeFieldInfo(inputs.TODO),
			"OSGuestTime":                              newGaugeFieldInfo(inputs.TODO),
			"MarkCacheBytes":                           newGaugeFieldInfo(inputs.TODO),
			"OSSoftIrqTime":                            newGaugeFieldInfo(inputs.TODO),
			"BlockWriteTime_sr0":                       newGaugeFieldInfo(inputs.TODO),
			"OSMemoryFreeWithoutCached":                newGaugeFieldInfo(inputs.TODO),
			"BlockWriteMerges_dm_0":                    newGaugeFieldInfo(inputs.TODO),
			"CompiledExpressionCacheBytes":             newGaugeFieldInfo(inputs.TODO),
			"CPUFrequencyMHz_0":                        newGaugeFieldInfo(inputs.TODO),
			"OSIOWaitTime":                             newGaugeFieldInfo(inputs.TODO),
			"OSIdleTimeCPU0":                           newGaugeFieldInfo(inputs.TODO),
			"LoadAverage15":                            newGaugeFieldInfo(inputs.TODO),
			"BlockReadOps_sr0":                         newGaugeFieldInfo(inputs.TODO),
			"OSMemoryCached":                           newGaugeFieldInfo(inputs.TODO),
			"OSMemoryAvailable":                        newGaugeFieldInfo(inputs.TODO),
			"OSUserTime":                               newGaugeFieldInfo(inputs.TODO),
			"OSIrqTimeCPU0":                            newGaugeFieldInfo(inputs.TODO),
			"NetworkSendErrors_ens33":                  newGaugeFieldInfo(inputs.TODO),
			"OSUptime":                                 newGaugeFieldInfo(inputs.TODO),
			"OSSoftIrqTimeCPU0":                        newGaugeFieldInfo(inputs.TODO),
			"BlockDiscardMerges_dm_0":                  newGaugeFieldInfo(inputs.TODO),
			"OSGuestTimeCPU0":                          newGaugeFieldInfo(inputs.TODO),
			"ReplicasSumInsertsInQueue":                newGaugeFieldInfo(inputs.TODO),
			"LoadAverage5":                             newGaugeFieldInfo(inputs.TODO),
			"LoadAverage1":                             newGaugeFieldInfo(inputs.TODO),
			"MaxPartCountForPartition":                 newGaugeFieldInfo(inputs.TODO),
			"OSIOWaitTimeNormalized":                   newGaugeFieldInfo(inputs.TODO),
			"jemalloc_active":                          newGaugeFieldInfo(inputs.TODO),
			"NetworkSendDrop_virbr0_nic":               newGaugeFieldInfo(inputs.TODO),
			"BlockReadTime_sr0":                        newGaugeFieldInfo(inputs.TODO),
			"OSGuestNiceTime":                          newGaugeFieldInfo(inputs.TODO),
			"ReplicasMaxRelativeDelay":                 newGaugeFieldInfo(inputs.TODO),
			"OSIdleTime":                               newGaugeFieldInfo(inputs.TODO),
			"NetworkReceivePackets_virbr0":             newGaugeFieldInfo(inputs.TODO),
			"BlockReadBytes_sr0":                       newGaugeFieldInfo(inputs.TODO),
			"UncompressedCacheBytes":                   newGaugeFieldInfo(inputs.TODO),
			"Uptime":                                   newGaugeFieldInfo(inputs.TODO),
			"OSThreadsTotal":                           newGaugeFieldInfo(inputs.TODO),
			"BlockReadBytes_dm_1":                      newGaugeFieldInfo(inputs.TODO),
			"MemoryShared":                             newGaugeFieldInfo(inputs.TODO),
			"OSUserTimeNormalized":                     newGaugeFieldInfo(inputs.TODO),
			"BlockInFlightOps_sda":                     newGaugeFieldInfo(inputs.TODO),
			"UncompressedCacheCells":                   newGaugeFieldInfo(inputs.TODO),
			"OSNiceTimeNormalized":                     newGaugeFieldInfo(inputs.TODO),
		},
		Tags: map[string]interface{}{
			"host": inputs.NewTagInfo("host name"),
		},
	}
}

//nolint:lll
func (m *MetricsMeasurement) Info() *inputs.MeasurementInfo {
	return &inputs.MeasurementInfo{
		Name: "ClickHouseMetrics",
		Type: "metric",
		Fields: map[string]interface{}{
			"Query":                                   newGaugeFieldInfo("Number of executing queries"),
			"Merge":                                   newGaugeFieldInfo("Number of executing background merges"),
			"PartMutation":                            newGaugeFieldInfo("Number of mutations (ALTER DELETE/UPDATE)"),
			"ReplicatedFetch":                         newGaugeFieldInfo("Number of data parts being fetched from replica"),
			"ReplicatedSend":                          newGaugeFieldInfo("Number of data parts being sent to replicas"),
			"ReplicatedChecks":                        newGaugeFieldInfo("Number of data parts checking for consistency"),
			"BackgroundMergesAndMutationsPoolTask":    newGaugeFieldInfo("Number of active merges and mutations in an associated background pool"),
			"BackgroundFetchesPoolTask":               newGaugeFieldInfo("Number of active fetches in an associated background pool"),
			"BackgroundCommonPoolTask":                newGaugeFieldInfo("Number of active tasks in an associated background pool"),
			"BackgroundMovePoolTask":                  newGaugeFieldInfo("Number of active tasks in BackgroundProcessingPool for moves"),
			"BackgroundSchedulePoolTask":              newGaugeFieldInfo("Number of active tasks in BackgroundSchedulePool. "),
			"BackgroundBufferFlushSchedulePoolTask":   newGaugeFieldInfo("Number of active tasks in BackgroundBufferFlushSchedulePool. This pool is used for periodic Buffer flushes"),
			"BackgroundDistributedSchedulePoolTask":   newGaugeFieldInfo("Number of active tasks in BackgroundDistributedSchedulePool. "),
			"BackgroundMessageBrokerSchedulePoolTask": newGaugeFieldInfo("Number of active tasks in BackgroundProcessingPool for message streaming"),
			"CacheDictionaryUpdateQueueBatches":       newGaugeFieldInfo("Number of 'batches' (a set of keys) in update queue in CacheDictionaries."),
			"CacheDictionaryUpdateQueueKeys":          newGaugeFieldInfo("Exact number of keys in update queue in CacheDictionaries."),
			"DiskSpaceReservedForMerge":               newGaugeFieldInfo("Disk space reserved for currently running background merges. It is slightly more than the total size of currently merging parts."),
			"DistributedSend":                         newGaugeFieldInfo("Number of connections to remote servers sending data that was INSERTed into Distributed tables. Both synchronous and asynchronous mode."),
			"QueryPreempted":                          newGaugeFieldInfo("Number of queries that are stopped and waiting due to 'priority' setting."),
			"TCPConnection":                           newGaugeFieldInfo("Number of connections to TCP server (clients with native interface), also included server-server distributed query connections"),
			"MySQLConnection":                         newGaugeFieldInfo("Number of client connections using MySQL protocol"),
			"HTTPConnection":                          newGaugeFieldInfo("Number of connections to HTTP server"),
			"InterserverConnection":                   newGaugeFieldInfo("Number of connections from other replicas to fetch parts"),
			"PostgreSQLConnection":                    newGaugeFieldInfo("Number of client connections using PostgreSQL protocol"),
			"OpenFileForRead":                         newGaugeFieldInfo("Number of files open for reading"),
			"OpenFileForWrite":                        newGaugeFieldInfo("Number of files open for writing"),
			"Read":                                    newGaugeFieldInfo("Number of read (read, pread, io_getevents, etc.) syscalls in fly"),
			"Write":                                   newGaugeFieldInfo("Number of write (write, pwrite, io_getevents, etc.) syscalls in fly"),
			"NetworkReceive":                          newGaugeFieldInfo("Number of threads receiving data from network. Only ClickHouse-related network interaction is included, not by 3rd party libraries."),
			"NetworkSend":                             newGaugeFieldInfo("Number of threads sending data to network. Only ClickHouse-related network interaction is included, not by 3rd party libraries."),
			"SendScalars":                             newGaugeFieldInfo("Number of connections that are sending data for scalars to remote servers."),
			"SendExternalTables":                      newGaugeFieldInfo("Number of connections that are sending data for external tables to remote servers. "),
			"QueryThread":                             newGaugeFieldInfo("Number of query processing threads"),
			"ReadonlyReplica":                         newGaugeFieldInfo("Number of Replicated tables that are currently in readonly state due to re-initialization after ZooKeeper session loss or due to startup without ZooKeeper configured."),
			"MemoryTracking":                          newGaugeFieldInfo("Total amount of memory (bytes) allocated by the server."),
			"EphemeralNode":                           newGaugeFieldInfo("Number of ephemeral nodes hold in ZooKeeper."),
			"ZooKeeperSession":                        newGaugeFieldInfo("Number of sessions (connections) to ZooKeeper."),
			"ZooKeeperWatch":                          newGaugeFieldInfo("Number of watches (event subscriptions) in ZooKeeper."),
			"ZooKeeperRequest":                        newGaugeFieldInfo("Number of requests to ZooKeeper in fly."),
			"DelayedInserts":                          newGaugeFieldInfo("Number of INSERT queries that are throttled due to high number of active data parts for partition in a MergeTree table."),
			"ContextLockWait":                         newGaugeFieldInfo("Number of threads waiting for lock in Context. This is global lock."),
			"StorageBufferRows":                       newGaugeFieldInfo("Number of rows in buffers of Buffer tables"),
			"StorageBufferBytes":                      newGaugeFieldInfo("Number of bytes in buffers of Buffer tables"),
			"DictCacheRequests":                       newGaugeFieldInfo("Number of requests in fly to data sources of dictionaries of cache type."),
			"Revision Revision":                       newGaugeFieldInfo("of the server. It is a number incremented for every release or release candidate except patch releases."),
			"VersionInteger":                          newGaugeFieldInfo("Version of the server in a single integer number in base-1000. For example, version 11.22.33 is translated to 11022033."),
			"RWLockWaitingReaders":                    newGaugeFieldInfo("Number of threads waiting for read on a table RWLock."),
			"RWLockWaitingWriters":                    newGaugeFieldInfo("Number of threads waiting for write on a table RWLock."),
			"RWLockActiveReaders":                     newGaugeFieldInfo("Number of threads holding read lock in a table RWLock."),
			"RWLockActiveWriters":                     newGaugeFieldInfo("Number of threads holding write lock in a table RWLock."),
			"GlobalThread":                            newGaugeFieldInfo("Number of threads in global thread pool."),
			"GlobalThreadActive":                      newGaugeFieldInfo("Number of threads in global thread pool running a task."),
			"LocalThread":                             newGaugeFieldInfo("Number of threads in local thread pools. The threads in local thread pools are taken from the global thread pool."),
			"LocalThreadActive":                       newGaugeFieldInfo("Number of threads in local thread pools running a task."),
			"DistributedFilesToInsert":                newGaugeFieldInfo("Number of pending files to process for asynchronous insertion into Distributed tables. Number of files for every shard is summed."),
			"BrokenDistributedFilesToInsert":          newGaugeFieldInfo("Number of files for asynchronous insertion into Distributed tables that has been marked as broken."),
			"TablesToDropQueueSize":                   newGaugeFieldInfo("Number of dropped tables, that are waiting for background data removal."),
			"MaxDDLEntryID":                           newGaugeFieldInfo("Max processed DDL entry of DDLWorker."),
			"MaxPushedDDLEntryID":                     newGaugeFieldInfo("Max DDL entry of DDLWorker that pushed to zookeeper."),
			"PartsTemporary":                          newGaugeFieldInfo("The part is generating now, it is not in data_parts list."),
			"PartsPreCommitted":                       newGaugeFieldInfo("The part is in data_parts, but not used for SELECTs."),
			"PartsCommitted":                          newGaugeFieldInfo("Active data part, used by current and upcoming SELECTs."),
			"PartsOutdated":                           newGaugeFieldInfo("Not active data part, but could be used by only current SELECTs, could be deleted after SELECTs finishes."),
			"PartsDeleting":                           newGaugeFieldInfo("Not active data part with identity refcounter, it is deleting right now by a cleaner."),
			"PartsDeleteOnDestroy":                    newGaugeFieldInfo("Part was moved to another disk and should be deleted in own destructor."),
			"PartsWide":                               newGaugeFieldInfo("Wide parts."),
			"PartsCompact":                            newGaugeFieldInfo("Compact parts."),
			"PartsInMemory":                           newGaugeFieldInfo("In-memory parts."),
			"MMappedFiles":                            newGaugeFieldInfo("Total number of mmapped files."),
			"MMappedFileBytes":                        newGaugeFieldInfo("Sum size of mmapped file regions."),
			"AsyncDrainedConnections":                 newGaugeFieldInfo("Number of connections drained asynchronously."),
			"ActiveAsyncDrainedConnections":           newGaugeFieldInfo("Number of active connections drained asynchronously."),
			"SyncDrainedConnections":                  newGaugeFieldInfo("Number of connections drained synchronously."),
			"ActiveSyncDrainedConnections":            newGaugeFieldInfo("Number of active connections drained synchronously."),
			"AsynchronousReadWait":                    newGaugeFieldInfo("Number of threads waiting for asynchronous read."),
		},
		Tags: map[string]interface{}{
			"host": inputs.NewTagInfo("host name"),
		},
	}
}

//nolint:lll,funlen
func (m *ProfileEventsMeasurement) Info() *inputs.MeasurementInfo {
	return &inputs.MeasurementInfo{
		Name: "ClickHouseProfileEvents",
		Type: "metric",
		Fields: map[string]interface{}{
			"ReadBufferFromFileDescriptorReadFailed ":          newCountFieldInfo("Number of times the read (read/pread) from a file descriptor have failed."),
			"ReadBufferFromFileDescriptorReadBytes ":           newCountFieldInfo("Number of bytes read from file descriptors. If the file is compressed, this will show the compressed data size."),
			"WriteBufferFromFileDescriptorWrite ":              newCountFieldInfo("Number of writes (write/pwrite) to a file descriptor. Does not include sockets"),
			"WriteBufferFromFileDescriptorWriteFailed ":        newCountFieldInfo("Number of times the write (write/pwrite) to a file descriptor have failed."),
			"WriteBufferFromFileDescriptorWriteBytes":          newCountFieldInfo("Number of bytes written to file descriptors. If the file is compressed, this will show compressed data size."),
			"ReadCompressedBytes":                              newCountFieldInfo("Number of bytes (the number of bytes before decompression) read from compressed sources (files, network)."),
			"CompressedReadBufferBlocks":                       newCountFieldInfo("CompressedReadBufferBlocks Number of compressed blocks (the blocks of data that are compressed independent of each other) read from compressed sources (files, network)."),
			"CompressedReadBufferBytes":                        newCountFieldInfo("Number of uncompressed bytes (the number of bytes after decompression) read from compressed sources (files, network)."),
			"AIOWrite":                                         newCountFieldInfo("Number of writes with Linux or FreeBSD AIO interface"),
			"AIOWriteBytes":                                    newCountFieldInfo("Number of bytes written with Linux or FreeBSD AIO interface"),
			"AIORead":                                          newCountFieldInfo("Number of reads with Linux or FreeBSD AIO interface"),
			"AIOReadBytes":                                     newCountFieldInfo("Number of bytes read with Linux or FreeBSD AIO interface"),
			"Query":                                            newCountFieldInfo("Number of queries to be interpreted and potentially executed."),
			"SelectQuery":                                      newCountFieldInfo("Same as Query, but only for SELECT queries."),
			"InsertQuery":                                      newCountFieldInfo("Same as Query, but only for INSERT queries"),
			"FailedQuery":                                      newCountFieldInfo("Number of failed queries."),
			"FailedSelectQuery":                                newCountFieldInfo("Same as FailedQuery, but only for SELECT queries"),
			"FailedInsertQuery":                                newCountFieldInfo("Same as FailedQuery, but only for INSERT queries"),
			"QueryTimeMicroseconds":                            newCountFieldInfo("Total time of all queries."),
			"SelectQueryTimeMicroseconds":                      newCountFieldInfo("Total time of SELECT queries."),
			"InsertQueryTimeMicroseconds":                      newCountFieldInfo("Total time of INSERT queries."),
			"FileOpen ":                                        newCountFieldInfo("Number of files opened"),
			"Seek ":                                            newCountFieldInfo("Number of times the 'lseek' function was called."),
			"ReadBufferFromFileDescriptorRead":                 newCountFieldInfo("Number of reads (read/pread) from a file descriptor. Does not include sockets."),
			"StorageBufferLayerLockReadersWaitMilliseconds":    newCountFieldInfo("Time for waiting for Buffer layer during reading"),
			"StorageBufferLayerLockWritersWaitMilliseconds":    newCountFieldInfo("Time for waiting free Buffer layer to write to (can be used to tune Buffer layers)"),
			"DiskReadElapsedMicroseconds":                      newCountFieldInfo("Total time spent waiting for read syscall. This include reads from page cache."),
			"DiskWriteElapsedMicroseconds":                     newCountFieldInfo("Total time spent waiting for write syscall. This include writes to page cache."),
			"NetworkReceiveElapsedMicroseconds":                newCountFieldInfo("Total time spent waiting for data to receive or receiving data from network. Only ClickHouse-related network interaction is included, not by 3rd party libraries."),
			"NetworkSendElapsedMicroseconds":                   newCountFieldInfo("Total time spent waiting for data to send to network or sending data to network. Only ClickHouse-related network interaction is included, not by 3rd party libraries.."),
			"NetworkReceiveBytes":                              newCountFieldInfo("Total number of bytes received from network. Only ClickHouse-related network interaction is included, not by 3rd party libraries."),
			"NetworkSendBytes":                                 newCountFieldInfo("Total number of bytes send to network. Only ClickHouse-related network interaction is included, not by 3rd party libraries."),
			"ThrottlerSleepMicroseconds":                       newCountFieldInfo("Total time a query was sleeping to conform the 'max_network_bandwidth' setting."),
			"QueryMaskingRulesMatch":                           newCountFieldInfo("Number of times query masking rules was successfully matched."),
			"ReplicatedPartFetches":                            newCountFieldInfo("Number of times a data part was downloaded from replica of a ReplicatedMergeTree table."),
			"ReplicatedPartFailedFetches":                      newCountFieldInfo("Number of times a data part was failed to download from replica of a ReplicatedMergeTree table."),
			"DistributedConnectionFailTry":                     newCountFieldInfo("Total count when distributed connection fails with retry"),
			"ReplicatedDataLoss":                               newCountFieldInfo("Number of times a data part that we wanted doesn't exist on any replica (even on replicas that are offline right now). "),
			"InsertedRows":                                     newCountFieldInfo("Number of rows inserted to all tables."),
			"InsertedBytes":                                    newCountFieldInfo("Number of bytes (uncompressed; for columns as they stored in memory) inserted to all tables."),
			"DelayedInserts":                                   newCountFieldInfo("Number of times the INSERT of a block to a MergeTree table was throttled due to high number of active data parts for partition."),
			"RejectedInserts":                                  newCountFieldInfo("Number of times the INSERT of a block to a MergeTree table was rejected with 'Too many parts' exception due to high number of active data parts for partition."),
			"DelayedInsertsMilliseconds":                       newCountFieldInfo("Total number of milliseconds spent while the INSERT of a block to a MergeTree table was throttled due to high number of active data parts for partition."),
			"DistributedDelayedInserts":                        newCountFieldInfo("Number of times the INSERT of a block to a Distributed table was throttled due to high number of pending bytes."),
			"DistributedRejectedInserts":                       newCountFieldInfo("Number of times the INSERT of a block to a Distributed table was rejected with 'Too many bytes' exception due to high number of pending bytes."),
			"DistributedDelayedInsertsMilliseconds":            newCountFieldInfo("Total number of milliseconds spent while the INSERT of a block to a Distributed table was throttled due to high number of pending bytes."),
			"DuplicatedInsertedBlocks":                         newCountFieldInfo("Number of times the INSERTed block to a ReplicatedMergeTree table was deduplicated."),
			"ReplicatedPartMerges":                             newCountFieldInfo("Number of times data parts of ReplicatedMergeTree tables were successfully merged."),
			"ReplicatedPartFetchesOfMerged":                    newCountFieldInfo("Number of times we prefer to download already merged part from replica of ReplicatedMergeTree table instead of performing a merge ourself."),
			"DistributedConnectionFailAtAll":                   newCountFieldInfo("Total count when distributed connection fails after all retries finished"),
			"HedgedRequestsChangeReplica":                      newCountFieldInfo("Total count when timeout for changing replica expired in hedged requests."),
			"CompileFunction":                                  newCountFieldInfo("Number of times a compilation of generated LLVM code (to create fused function for complex expressions) was initiated."),
			"CompiledFunctionExecute":                          newCountFieldInfo("Number of times a compiled function was executed."),
			"CompileExpressionsMicroseconds":                   newCountFieldInfo("Total time spent for compilation of expressions to LLVM code."),
			"CompileExpressionsBytes":                          newCountFieldInfo("Number of bytes used for expressions compilation."),
			"SlowRead":                                         newCountFieldInfo("Number of reads from a file that were slow. This indicate system overload. Thresholds are controlled by read_backoff_* settings."),
			"ReadBackoff":                                      newCountFieldInfo("Number of times the number of query processing threads was lowered due to slow reads."),
			"ReplicaPartialShutdown":                           newCountFieldInfo("How many times Replicated table has to deinitialize its state due to session expiration in ZooKeeper. "),
			"SelectedParts":                                    newCountFieldInfo("Number of data parts selected to read from a MergeTree table."),
			"SelectedRanges":                                   newCountFieldInfo("Number of (non-adjacent) ranges in all data parts selected to read from a MergeTree table."),
			"SelectedMarks":                                    newCountFieldInfo("Number of marks (index granules) selected to read from a MergeTree table."),
			"SelectedRows":                                     newCountFieldInfo("Number of rows selected from all tables."),
			"SelectedBytes":                                    newCountFieldInfo("Number of bytes (uncompressed; for columns as they stored in memory) SELECTed from all tables."),
			"Merge":                                            newCountFieldInfo("Number of launched background merges."),
			"MergedRows":                                       newCountFieldInfo("Rows read for background merges. This is the number of rows before merge."),
			"MergedUncompressedBytes":                          newCountFieldInfo("Uncompressed bytes (for columns as they stored in memory) that was read for background merges. This is the number before merge."),
			"MergesTimeMilliseconds":                           newCountFieldInfo("Total time spent for background merges."),
			"MergeTreeDataWriterRows":                          newCountFieldInfo("Number of rows INSERTed to MergeTree tables."),
			"MergeTreeDataWriterUncompressedBytes":             newCountFieldInfo("Uncompressed bytes (for columns as they stored in memory) INSERTed to MergeTree tables."),
			"MergeTreeDataWriterCompressedBytes":               newCountFieldInfo("Bytes written to filesystem for data INSERTed to MergeTree tables."),
			"MergeTreeDataWriterBlocks":                        newCountFieldInfo("Number of blocks INSERTed to MergeTree tables. Each block forms a data part of level zero."),
			"MergeTreeDataWriterBlocksAlreadySorted":           newCountFieldInfo("Number of blocks INSERTed to MergeTree tables that appeared to be already sorted."),
			"MergeTreeDataProjectionWriterRows":                newCountFieldInfo("Number of rows INSERTed to MergeTree tables projection."),
			"MergeTreeDataProjectionWriterUncompressedBytes":   newCountFieldInfo("Uncompressed bytes (for columns as they stored in memory) INSERTed to MergeTree tables projection."),
			"MergeTreeDataProjectionWriterCompressedBytes":     newCountFieldInfo("Bytes written to filesystem for data INSERTed to MergeTree tables projection."),
			"MergeTreeDataProjectionWriterBlocks":              newCountFieldInfo("Number of blocks INSERTed to MergeTree tables projection. Each block forms a data part of level zero."),
			"MergeTreeDataProjectionWriterBlocksAlreadySorted": newCountFieldInfo("Number of blocks INSERTed to MergeTree tables projection that appeared to be already sorted."),
			"CannotRemoveEphemeralNode":                        newCountFieldInfo("Number of times an error happened while trying to remove ephemeral node. "),
			"RegexpCreated":                                    newCountFieldInfo("Compiled regular expressions. Identical regular expressions compiled just once and cached forever."),
			"ContextLock":                                      newCountFieldInfo("Number of times the lock of Context was acquired or tried to acquire. This is global lock."),
			"DNSError":                                         newCountFieldInfo("Total count of errors in DNS resolution"),
			"RealTimeMicroseconds":                             newCountFieldInfo("Total (wall clock) time spent in processing (queries and other tasks) threads (not that this is a sum)."),
			"UserTimeMicroseconds":                             newCountFieldInfo("Total time spent in processing (queries and other tasks) threads executing CPU instructions in user space. "),
			"SystemTimeMicroseconds":                           newCountFieldInfo("Total time spent in processing (queries and other tasks) threads executing CPU instructions in OS kernel space. "),
			"OSIOWaitMicroseconds":                             newCountFieldInfo("Total time a thread spent waiting for a result of IO operation, from the OS point of view. This is real IO that doesn't include page cache."),
			"OSCPUWaitMicroseconds":                            newCountFieldInfo("Total time a thread was ready for execution but waiting to be scheduled by OS, from the OS point of view."),
			"OSCPUVirtualTimeMicroseconds":                     newCountFieldInfo("CPU time spent seen by OS. Does not include involuntary waits due to virtualization."),
			"OSReadBytes":                                      newCountFieldInfo("Number of bytes read from disks or block devices. Doesn't include bytes read from page cache. "),
			"OSWriteBytes":                                     newCountFieldInfo("Number of bytes written to disks or block devices. Doesn't include bytes that are in page cache dirty pages. "),
			"OSReadChars":                                      newCountFieldInfo("Number of bytes read from filesystem, including page cache."),
			"OSWriteChars":                                     newCountFieldInfo("Number of bytes written to filesystem, including page cache."),
			"PerfCpuCycles":                                    newCountFieldInfo("Total cycles. Be wary of what happens during CPU frequency scaling."),
			"PerfInstructions":                                 newCountFieldInfo("Retired instructions. Be careful, these can be affected by various issues, most notably hardware interrupt counts."),
			"PerfCacheReferences":                              newCountFieldInfo("Cache accesses. Usually this indicates Last Level Cache accesses but this may vary depending on your CPU. "),
			"PerfCacheMisses":                                  newCountFieldInfo("Cache misses. Usually this indicates Last Level Cache misses."),
			"PerfBranchInstructions":                           newCountFieldInfo("Retired branch instructions. Prior to Linux 2.6.35, this used the wrong event on AMD processors."),
			"PerfBranchMisses":                                 newCountFieldInfo("Mispredicted branch instructions."),
			"PerfBusCycles":                                    newCountFieldInfo("Bus cycles, which can be different from total cycles."),
			"PerfStalledCyclesFrontend":                        newCountFieldInfo("Stalled cycles during issue."),
			"PerfStalledCyclesBackend":                         newCountFieldInfo("Stalled cycles during retirement."),
			"PerfRefCpuCycles":                                 newCountFieldInfo("Total cycles; not affected by CPU frequency scaling."),
			"PerfCpuClock":                                     newCountFieldInfo("The CPU clock, a high-resolution per-CPU timer"),
			"PerfTaskClock":                                    newCountFieldInfo("A clock count specific to the task that is running"),
			"PerfContextSwitches":                              newCountFieldInfo("Number of context switches"),
			"PerfCpuMigrations":                                newCountFieldInfo("Number of times the process has migrated to a new CPU"),
			"PerfAlignmentFaults":                              newCountFieldInfo("Number of alignment faults. These happen when unaligned memory accesses happen; the kernel can handle these but it reduces performance."),
			"PerfEmulationFaults":                              newCountFieldInfo("Number of emulation faults. The kernel sometimes traps on unimplemented instructions and emulates them for user space."),
			"PerfMinEnabledTime":                               newCountFieldInfo("For all events, minimum time that an event was enabled. Used to track event multiplexing influence"),
			"PerfMinEnabledRunningTime":                        newCountFieldInfo("Running time for event with minimum enabled time. Used to track the amount of event multiplexing"),
			"PerfDataTLBReferences":                            newCountFieldInfo("Data TLB references"),
			"PerfDataTLBMisses":                                newCountFieldInfo("Data TLB misses"),
			"PerfInstructionTLBReferences":                     newCountFieldInfo("Instruction TLB references"),
			"PerfInstructionTLBMisses":                         newCountFieldInfo("Instruction TLB misses"),
			"PerfLocalMemoryReferences":                        newCountFieldInfo("Local NUMA node memory reads"),
			"PerfLocalMemoryMisses":                            newCountFieldInfo("Local NUMA node memory read misses"),
			"CreatedHTTPConnections":                           newCountFieldInfo("Total amount of created HTTP connections (counter increase every time connection is created)."),
			"CannotWriteToWriteBufferDiscard":                  newCountFieldInfo("Number of stack traces dropped by query profiler or signal handler because pipe is full or cannot write to pipe."),
			"QueryProfilerSignalOverruns":                      newCountFieldInfo("Number of times we drop processing of a query profiler signal due to overrun plus the number of signals that OS has not delivered due to overrun."),
			"QueryProfilerRuns":                                newCountFieldInfo("Number of times QueryProfiler had been run."),
			"CreatedLogEntryForMerge":                          newCountFieldInfo("Successfully created log entry to merge parts in ReplicatedMergeTree."),
			"NotCreatedLogEntryForMerge":                       newCountFieldInfo("Log entry to merge parts in ReplicatedMergeTree is not created due to concurrent log update by another replica."),
			"CreatedLogEntryForMutation":                       newCountFieldInfo("Successfully created log entry to mutate parts in ReplicatedMergeTree."),
			"NotCreatedLogEntryForMutation":                    newCountFieldInfo("Log entry to mutate parts in ReplicatedMergeTree is not created due to concurrent log update by another replica."),
			"S3ReadMicroseconds":                               newCountFieldInfo("Time of GET and HEAD requests to S3 storage."),
			"S3ReadBytes":                                      newCountFieldInfo("Read bytes (incoming) in GET and HEAD requests to S3 storage."),
			"S3ReadRequestsCount":                              newCountFieldInfo("Number of GET and HEAD requests to S3 storage."),
			"S3ReadRequestsErrors":                             newCountFieldInfo("Number of non-throttling errors in GET and HEAD requests to S3 storage."),
			"S3ReadRequestsThrottling":                         newCountFieldInfo("Number of 429 and 503 errors in GET and HEAD requests to S3 storage."),
			"S3ReadRequestsRedirects":                          newCountFieldInfo("Number of redirects in GET and HEAD requests to S3 storage."),
			"S3WriteMicroseconds":                              newCountFieldInfo("Time of POST, DELETE, PUT and PATCH requests to S3 storage."),
			"S3WriteBytes":                                     newCountFieldInfo("Write bytes (outgoing) in POST, DELETE, PUT and PATCH requests to S3 storage."),
			"S3WriteRequestsCount":                             newCountFieldInfo("Number of POST, DELETE, PUT and PATCH requests to S3 storage."),
			"S3WriteRequestsErrors":                            newCountFieldInfo("Number of non-throttling errors in POST, DELETE, PUT and PATCH requests to S3 storage."),
			"S3WriteRequestsThrottling":                        newCountFieldInfo("Number of 429 and 503 errors in POST, DELETE, PUT and PATCH requests to S3 storage."),
			"S3WriteRequestsRedirects":                         newCountFieldInfo("Number of redirects in POST, DELETE, PUT and PATCH requests to S3 storage."),
			"QueryMemoryLimitExceeded":                         newCountFieldInfo("Number of times when memory limit exceeded for query."),
			"RemoteFSReadMicroseconds":                         newCountFieldInfo("Time of reading from remote filesystem."),
			"RemoteFSReadBytes":                                newCountFieldInfo("Read bytes from remote filesystem."),
			"RemoteFSSeeks":                                    newCountFieldInfo("Total number of seeks for async buffer"),
			"RemoteFSPrefetches":                               newCountFieldInfo("Number of prefetches made with asynchronous reading from remote filesystem"),
			"RemoteFSCancelledPrefetches":                      newCountFieldInfo("Number of canceled prefecthes (because of seek)"),
			"RemoteFSUnusedPrefetches":                         newCountFieldInfo("Number of prefetches pending at buffer destruction"),
			"RemoteFSPrefetchedReads":                          newCountFieldInfo("Number of reads from prefecthed buffer"),
			"RemoteFSUnprefetchedReads":                        newCountFieldInfo("Number of reads from unprefetched buffer"),
			"RemoteFSBuffers":                                  newCountFieldInfo("Number of buffers created for asynchronous reading from remote filesystem"),
			"SleepFunctionCalls":                               newCountFieldInfo("Number of times a sleep function (sleep, sleepEachRow) has been called."),
			"SleepFunctionMicroseconds":                        newCountFieldInfo("Time spent sleeping due to a sleep function call."),
			"ThreadPoolReaderPageCacheHit":                     newCountFieldInfo("Number of times the read inside ThreadPoolReader was done from page cache."),
			"ThreadPoolReaderPageCacheHitBytes":                newCountFieldInfo("Number of bytes read inside ThreadPoolReader when it was done from page cache."),
			"ThreadPoolReaderPageCacheHitElapsedMicroseconds":  newCountFieldInfo("Time spent reading data from page cache in ThreadPoolReader."),
			"ThreadPoolReaderPageCacheMiss":                    newCountFieldInfo("Number of times the read inside ThreadPoolReader was not done from page cache and was hand off to thread pool."),
			"ThreadPoolReaderPageCacheMissBytes":               newCountFieldInfo("Number of bytes read inside ThreadPoolReader when read was not done from page cache and was hand off to thread pool."),
			"ThreadPoolReaderPageCacheMissElapsedMicroseconds": newCountFieldInfo("Time spent reading data inside the asynchronous job in ThreadPoolReader - when read was not done from page cache."),
			"AsynchronousReadWaitMicroseconds":                 newCountFieldInfo("Time spent in waiting for asynchronous reads."),
			"ReplicatedPartMutations":                          newCountFieldInfo(inputs.TODO),
			"ReplicatedPartChecks":                             newCountFieldInfo(inputs.TODO),
			"ReplicatedPartChecksFailed":                       newCountFieldInfo(inputs.TODO),
			"ObsoleteReplicatedParts":                          newCountFieldInfo(inputs.TODO),
			"ZooKeeperInit":                                    newCountFieldInfo(inputs.TODO),
			"ZooKeeperTransactions":                            newCountFieldInfo(inputs.TODO),
			"ZooKeeperList":                                    newCountFieldInfo(inputs.TODO),
			"ZooKeeperCreate":                                  newCountFieldInfo(inputs.TODO),
			"ZooKeeperRemove":                                  newCountFieldInfo(inputs.TODO),
			"ZooKeeperExists":                                  newCountFieldInfo(inputs.TODO),
			"ZooKeeperGet":                                     newCountFieldInfo(inputs.TODO),
			"ZooKeeperSet":                                     newCountFieldInfo(inputs.TODO),
			"ZooKeeperMulti":                                   newCountFieldInfo(inputs.TODO),
			"ZooKeeperCheck":                                   newCountFieldInfo(inputs.TODO),
			"ZooKeeperClose":                                   newCountFieldInfo(inputs.TODO),
			"ZooKeeperWatchResponse":                           newCountFieldInfo(inputs.TODO),
			"ZooKeeperUserExceptions":                          newCountFieldInfo(inputs.TODO),
			"ZooKeeperHardwareExceptions":                      newCountFieldInfo(inputs.TODO),
			"ZooKeeperOtherExceptions":                         newCountFieldInfo(inputs.TODO),
			"ZooKeeperWaitMicroseconds":                        newCountFieldInfo(inputs.TODO),
			"ZooKeeperBytesSent":                               newCountFieldInfo(inputs.TODO),
			"ZooKeeperBytesReceived":                           newCountFieldInfo(inputs.TODO),
			"ExternalSortWritePart":                            newCountFieldInfo(inputs.TODO),
			"ExternalSortMerge":                                newCountFieldInfo(inputs.TODO),
			"ExternalAggregationWritePart":                     newCountFieldInfo(inputs.TODO),
			"ExternalAggregationMerge":                         newCountFieldInfo(inputs.TODO),
			"ExternalAggregationCompressedBytes":               newCountFieldInfo(inputs.TODO),
			"ExternalAggregationUncompressedBytes":             newCountFieldInfo(inputs.TODO),
			"DistributedConnectionMissingTable":                newCountFieldInfo(inputs.TODO),
			"DistributedConnectionStaleReplica":                newCountFieldInfo(inputs.TODO),
			"IOBufferAllocs":                                   newCountFieldInfo(inputs.TODO),
			"IOBufferAllocBytes":                               newCountFieldInfo(inputs.TODO),
			"ArenaAllocChunks":                                 newCountFieldInfo(inputs.TODO),
			"ArenaAllocBytes":                                  newCountFieldInfo(inputs.TODO),
			"FunctionExecute":                                  newCountFieldInfo(inputs.TODO),
			"TableFunctionExecute":                             newCountFieldInfo(inputs.TODO),
			"MarkCacheHits":                                    newCountFieldInfo(inputs.TODO),
			"MarkCacheMisses":                                  newCountFieldInfo(inputs.TODO),
			"CreatedReadBufferOrdinary":                        newCountFieldInfo(inputs.TODO),
			"CreatedReadBufferDirectIO":                        newCountFieldInfo(inputs.TODO),
			"CreatedReadBufferDirectIOFailed":                  newCountFieldInfo(inputs.TODO),
			"CreatedReadBufferMMap":                            newCountFieldInfo(inputs.TODO),
			"CreatedReadBufferMMapFailed":                      newCountFieldInfo(inputs.TODO),
			"StorageBufferFlush":                               newCountFieldInfo(inputs.TODO),
			"StorageBufferErrorOnFlush":                        newCountFieldInfo(inputs.TODO),
			"StorageBufferPassedAllMinThresholds":              newCountFieldInfo(inputs.TODO),
			"StorageBufferPassedTimeMaxThreshold":              newCountFieldInfo(inputs.TODO),
			"StorageBufferPassedRowsMaxThreshold":              newCountFieldInfo(inputs.TODO),
			"StorageBufferPassedBytesMaxThreshold":             newCountFieldInfo(inputs.TODO),
			"StorageBufferPassedTimeFlushThreshold":            newCountFieldInfo(inputs.TODO),
			"StorageBufferPassedRowsFlushThreshold":            newCountFieldInfo(inputs.TODO),
			"StorageBufferPassedBytesFlushThreshold":           newCountFieldInfo(inputs.TODO),
			"DictCacheKeysRequested":                           newCountFieldInfo(inputs.TODO),
			"DictCacheKeysRequestedMiss":                       newCountFieldInfo(inputs.TODO),
			"DictCacheKeysRequestedFound":                      newCountFieldInfo(inputs.TODO),
			"DictCacheKeysExpired":                             newCountFieldInfo(inputs.TODO),
			"DictCacheKeysNotFound":                            newCountFieldInfo(inputs.TODO),
			"DictCacheKeysHit":                                 newCountFieldInfo(inputs.TODO),
			"DictCacheRequestTimeNs":                           newCountFieldInfo(inputs.TODO),
			"DictCacheRequests":                                newCountFieldInfo(inputs.TODO),
			"DictCacheLockWriteNs":                             newCountFieldInfo(inputs.TODO),
			"DictCacheLockReadNs":                              newCountFieldInfo(inputs.TODO),
			"DistributedSyncInsertionTimeoutExceeded":          newCountFieldInfo(inputs.TODO),
			"DataAfterMergeDiffersFromReplica":                 newCountFieldInfo(inputs.TODO),
			"DataAfterMutationDiffersFromReplica":              newCountFieldInfo(inputs.TODO),
			"PolygonsAddedToPool":                              newCountFieldInfo(inputs.TODO),
			"PolygonsInPoolAllocatedBytes":                     newCountFieldInfo(inputs.TODO),
			"RWLockAcquiredReadLocks":                          newCountFieldInfo(inputs.TODO),
			"RWLockAcquiredWriteLocks":                         newCountFieldInfo(inputs.TODO),
			"RWLockReadersWaitMilliseconds":                    newCountFieldInfo(inputs.TODO),
			"RWLockWritersWaitMilliseconds":                    newCountFieldInfo(inputs.TODO),
			"SoftPageFaults":                                   newCountFieldInfo(inputs.TODO),
			"HardPageFaults":                                   newCountFieldInfo(inputs.TODO),
			"VoluntaryContextSwitches":                         newCountFieldInfo(inputs.TODO),
			"InvoluntaryContextSwitches":                       newCountFieldInfo(inputs.TODO),
		},
		Tags: map[string]interface{}{
			"host": inputs.NewTagInfo("host name"),
		},
	}
}

//nolint:lll
func (m *StatusInfoMeasurement) Info() *inputs.MeasurementInfo {
	return &inputs.MeasurementInfo{
		Name: "ClickHouseStatusInfo",
		Type: "metric",
		Fields: map[string]interface{}{
			"DictionaryStatus": newGaugeFieldInfo("Dictionary Status."),
		},
		Tags: map[string]interface{}{
			"host": inputs.NewTagInfo("host name"),
		},
	}
}

func newCountFieldInfo(desc string) *inputs.FieldInfo {
	return &inputs.FieldInfo{
		DataType: inputs.Int,
		Type:     inputs.Count,
		Unit:     inputs.NCount,
		Desc:     desc,
	}
}

//nolint:unparam
func newGaugeFieldInfo(desc string) *inputs.FieldInfo {
	return &inputs.FieldInfo{
		DataType: inputs.Int,
		Type:     inputs.Gauge,
		Unit:     inputs.NCount,
		Desc:     desc,
	}
}
